package java44th.group.controller.admin.dashboard;

import java44th.group.bean.admin.vo.BaseRespVo;
import java44th.group.bean.admin.vo.dashboard.DashboardVo;
import java44th.group.service.admin.dashboard.DashboardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ProjectName project-second
 * @Descriptiom TODO
 * @Aurhor: 蔡文强
 * @Since: 2022/10/11 21:15
 */
@RestController
public class DashboardController {

    @Autowired
    DashboardService dashboardService;

    @RequestMapping("/admin/dashboard")
    public BaseRespVo dashboard(){
        // 获取当前日期 yyyy-MM-dd
        // Date date = new Date();
        // SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        // String currentDate = simpleDateFormat.format(date);
        //dashboardVo dashboardVo = new dashboardVo(currentDate,200,null,"/admin/dashboard");

        int goodsTotal = dashboardService.queryGoodsTotal();
        int userTotal = dashboardService.queryUserTotal();
        int productTotal = dashboardService.queryProductTotal();
        int orderTotal = dashboardService.queryOrderTotal();

        DashboardVo dashboardVo = new DashboardVo(goodsTotal, userTotal, productTotal, orderTotal);

        return BaseRespVo.ok(dashboardVo);
    }

}
